<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="刘清政">
  <meta name="keyword" content="hexo-theme">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      python/前端/5-CSS3基础样式 | Justin-刘清政的博客
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/plugins/gitment.css">

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
    
<script src="/js/gitment.js"></script>

  
  

  
<meta name="generator" content="Hexo 4.2.0"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>Justin-刘清政的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于我</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于我</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>python/前端/5-CSS3基础样式</h2>



  <p class="post-date">2020-11-03</p>
    <!-- 不蒜子统计 -->
    <span id="busuanzi_container_page_pv" style='display:none' class="">
        <i class="icon-smile icon"></i> 阅读数：<span id="busuanzi_value_page_pv"></span>次
    </span>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h2 id="1、宽和高"><a href="#1、宽和高" class="headerlink" title="1、宽和高"></a>1、宽和高</h2><p>width属性可以为元素设置宽度。</p>
<p>height属性可以为元素设置高度。</p>
<p>块级标签才能设置宽度，内联标签的宽度由内容来决定(行内标签无法设置宽度，设置了也不会生效)。</p>
<h3 id="案例"><a href="#案例" class="headerlink" title="案例"></a>案例</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        p &#123;</span><br><span class="line">            background-color: red;</span><br><span class="line">            height: 200px;</span><br><span class="line">            width: 400px;</span><br><span class="line">        &#125;</span><br><span class="line">        span &#123;</span><br><span class="line">            background-color: green;</span><br><span class="line">            height: 200px;</span><br><span class="line">            width: 400px;</span><br><span class="line"><span class="css">            <span class="comment">/*行内标签无法设置长宽 就算你写了 也不会生效*/</span></span></span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>ppp<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">span</span>&gt;</span>span<span class="tag">&lt;/<span class="name">span</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="2、字体属性"><a href="#2、字体属性" class="headerlink" title="2、字体属性"></a>2、字体属性</h2><h3 id="2-1-文字字体"><a href="#2-1-文字字体" class="headerlink" title="2-1 文字字体"></a>2-1 文字字体</h3><p>font-family可以把多个字体名称作为一个“回退”系统来保存。如果浏览器不支持第一个字体，则会尝试下一个。浏览器会使用它可识别的第一个值。</p>
<p> 简单实例：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">body &#123;</span><br><span class="line">  font-family: &quot;Microsoft Yahei&quot;, &quot;微软雅黑&quot;, &quot;Arial&quot;, sans-serif</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="2-2-字体大小"><a href="#2-2-字体大小" class="headerlink" title="2-2 字体大小"></a>2-2 字体大小</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">p</span> &#123;</span><br><span class="line">  <span class="attribute">font-size</span>: <span class="number">14px</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>如果设置成inherit表示继承父元素的字体大小值。</p>
<h3 id="2-3-字重（粗细）"><a href="#2-3-字重（粗细）" class="headerlink" title="2-3 字重（粗细）"></a>2-3 字重（粗细）</h3><p>font-weight用来设置字体的字重（粗细）。</p>
<table>
<thead>
<tr>
<th align="center">值</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">normal</td>
<td align="center">默认值，标准粗细</td>
</tr>
<tr>
<td align="center">bold</td>
<td align="center">粗体</td>
</tr>
<tr>
<td align="center">bolder</td>
<td align="center">更粗</td>
</tr>
<tr>
<td align="center">lighter</td>
<td align="center">更细</td>
</tr>
<tr>
<td align="center">100~900</td>
<td align="center">设置具体粗细，400等同于normal，而700等同于bold</td>
</tr>
<tr>
<td align="center">inherit</td>
<td align="center">继承父元素字体的粗细值</td>
</tr>
</tbody></table>
<h3 id="2-4-文本颜色"><a href="#2-4-文本颜色" class="headerlink" title="2-4 文本颜色"></a>2-4 文本颜色</h3><p>颜色属性被用来设置文字的颜色。</p>
<p>颜色是通过CSS最经常的指定：</p>
<ul>
<li>十六进制值 - 如: <strong>＃</strong>FF0000</li>
<li>一个RGB值 - 如: RGB(255,0,0)</li>
<li>颜色的名称 - 如:  red</li>
</ul>
<p>还有rgba(255,0,0,0.3)，第四个值为alpha, 指定了色彩的透明度/不透明度，它的范围为0.0到1.0之间。</p>
<h3 id="2-5-总结"><a href="#2-5-总结" class="headerlink" title="2-5 总结"></a>2-5 总结</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*字族：STSong作为首选字体, 微软雅黑作为备用字体*/</span></span><br><span class="line"><span class="selector-tag">font-family</span>: "<span class="selector-tag">STSong</span>", "微软雅黑";</span><br><span class="line"><span class="comment">/*字体大小*/</span></span><br><span class="line"><span class="selector-tag">font-size</span>: 40<span class="selector-tag">px</span>;</span><br><span class="line"><span class="comment">/*字重：100、200、300、400、500、600、700、800、900，值越大字越粗*/</span></span><br><span class="line"><span class="selector-tag">font-weight</span>: 900;</span><br><span class="line"><span class="comment">/*行高: 字体文本默认在行高中垂直居中显示*/</span></span><br><span class="line"><span class="selector-tag">line-height</span>: 200<span class="selector-tag">px</span>;</span><br><span class="line"><span class="comment">/*字划线: overline(上划线) | line-through(中划线) | underline(下划线) | none(取消划线)  */</span></span><br><span class="line"><span class="selector-tag">text-decoration</span>: <span class="selector-tag">overline</span>;</span><br><span class="line"><span class="comment">/*字间距*/</span></span><br><span class="line"><span class="selector-tag">letter-spacing</span>: 2<span class="selector-tag">px</span>;</span><br><span class="line"><span class="comment">/*词间距*/</span></span><br><span class="line"><span class="selector-tag">word-spacing</span>: 5<span class="selector-tag">px</span>;</span><br><span class="line"><span class="comment">/*首行缩进：1em相当于一个字的宽度*/</span></span><br><span class="line"><span class="selector-tag">text-indent</span>: 2<span class="selector-tag">em</span>;</span><br><span class="line"><span class="comment">/*字体颜色*/</span></span><br><span class="line"><span class="selector-tag">color</span>: <span class="selector-tag">red</span>;</span><br><span class="line"><span class="comment">/* 文本水平排列方式：left(水平居左) | center(水平居中) | right(水平居右) */</span></span><br><span class="line"><span class="selector-tag">text-align</span>: <span class="selector-tag">center</span>;</span><br></pre></td></tr></table></figure>

<h3 id="2-6-案例"><a href="#2-6-案例" class="headerlink" title="2-6 案例"></a>2-6 案例</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        p &#123;</span><br><span class="line"><span class="css">            <span class="comment">/*font-family: "Arial Black","微软雅黑","...";  !*第一个不生效就用后面的 写多个备用*!*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*font-size: 24px;  !*字体大小*!*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*font-weight: inherit;  !*bolder lighter 100~900 inherit继承父元素的粗细值*!*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*color: red;  !*直接写颜色英文*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*color: #ee762e;  !*颜色编号*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*color: rgb(128,23,45);  !*三基色 数字  范围0-255*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*color: rgba(23, 128, 91, 0.9);  !*第四个参数是颜色的透明度 范围是0-1*!*/</span></span></span><br><span class="line"></span><br><span class="line">            /*当你想要一些颜色的时候 可以利用现成的工具</span><br><span class="line">                1 pycharm提供的取色器</span><br><span class="line">                2 qq或者微信截图功能</span><br><span class="line"></span><br><span class="line">                微信公众号:软件管家...</span><br><span class="line">            */</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span>曹老板 抬人！！！fuck off!<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="文字属性"><a href="#文字属性" class="headerlink" title="文字属性"></a>文字属性</h2><h3 id="3-1-文字对齐"><a href="#3-1-文字对齐" class="headerlink" title="3-1 文字对齐"></a>3-1 文字对齐</h3><p>text-align 属性规定元素中的文本的水平对齐方式。</p>
<table>
<thead>
<tr>
<th align="center">值</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">left</td>
<td align="center">左边对齐 默认值</td>
</tr>
<tr>
<td align="center">right</td>
<td align="center">右对齐</td>
</tr>
<tr>
<td align="center">center</td>
<td align="center">居中对齐</td>
</tr>
<tr>
<td align="center">justify</td>
<td align="center">两端对齐</td>
</tr>
</tbody></table>
<h3 id="3-2-文字装饰"><a href="#3-2-文字装饰" class="headerlink" title="3-2 文字装饰"></a>3-2 文字装饰</h3><p>text-decoration 属性用来给文字添加特殊效果。</p>
<table>
<thead>
<tr>
<th align="center">值</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">none</td>
<td align="center">默认。定义标准的文本。</td>
</tr>
<tr>
<td align="center">underline</td>
<td align="center">定义文本下的一条线。</td>
</tr>
<tr>
<td align="center">overline</td>
<td align="center">定义文本上的一条线。</td>
</tr>
<tr>
<td align="center">line-through</td>
<td align="center">定义穿过文本下的一条线。</td>
</tr>
<tr>
<td align="center">inherit</td>
<td align="center">继承父元素的text-decoration属性的值。</td>
</tr>
</tbody></table>
<p>常用的为去掉a标签默认的自划线：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">a</span> &#123;</span><br><span class="line">  <span class="attribute">text-decoration</span>: none;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="3-3-首行缩进"><a href="#3-3-首行缩进" class="headerlink" title="3-3 首行缩进"></a>3-3 首行缩进</h3><p>将段落的第一行缩进 32像素：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">p</span> &#123;</span><br><span class="line">  <span class="attribute">text-indent</span>: <span class="number">32px</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="3-4-案例"><a href="#3-4-案例" class="headerlink" title="3-4 案例"></a>3-4 案例</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        p &#123;</span><br><span class="line"><span class="css">            <span class="comment">/*text-align: center;  !*居中*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*text-align: right;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*text-align: left;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*text-align: justify;  !*两端对齐*!*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*text-decoration: underline;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*text-decoration: overline;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*text-decoration: line-through;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*text-decoration: none;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*在html中 有很多标签渲染出来的样式效果是一样的*/</span></span></span><br><span class="line">            font-size: 16px;</span><br><span class="line"><span class="css">            <span class="selector-tag">text-indent</span>: 32<span class="selector-tag">px</span>;   <span class="comment">/*缩进32px*/</span></span></span><br><span class="line">        &#125;</span><br><span class="line">        a &#123;</span><br><span class="line"><span class="css">            <span class="selector-tag">text-decoration</span>: <span class="selector-tag">none</span>;  <span class="comment">/*主要用于给a标签去掉自带的下划线  需要掌握*/</span></span></span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!--    &lt;p&gt;我要感谢我的导师，要不是他，我论文早写完了（狗头）&lt;/p&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--&lt;a href="https://www.mzitu.com/"&gt;点我&lt;/a&gt;--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>我要感谢我的导师，要不是他，我论文早写完了（狗头）,我要感谢我的导师，要不是他，我论文早写完了（狗头）,我要感谢我的导师，要不是他，我论文早写完了（狗头）<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="4、背景属性"><a href="#4、背景属性" class="headerlink" title="4、背景属性"></a>4、背景属性</h2><h3 id="4-1-基本使用"><a href="#4-1-基本使用" class="headerlink" title="4-1 基本使用"></a>4-1 基本使用</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*背景颜色*/</span></span><br><span class="line"><span class="selector-tag">background-color</span>: <span class="selector-tag">red</span>;</span><br><span class="line"><span class="comment">/*背景图片*/</span></span><br><span class="line">background-image: url('1.jpg');</span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> 背景重复</span></span><br><span class="line"><span class="comment"> repeat(默认):背景图片平铺排满整个网页</span></span><br><span class="line"><span class="comment"> repeat-x：背景图片只在水平方向上平铺</span></span><br><span class="line"><span class="comment"> repeat-y：背景图片只在垂直方向上平铺</span></span><br><span class="line"><span class="comment"> no-repeat：背景图片不平铺</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="selector-tag">background-repeat</span>: <span class="selector-tag">no-repeat</span>; </span><br><span class="line"><span class="comment">/*背景位置*/</span></span><br><span class="line"><span class="selector-tag">background-position</span>: <span class="selector-tag">left</span> <span class="selector-tag">top</span>;</span><br><span class="line"><span class="comment">/*background-position: 200px 200px;*/</span></span><br></pre></td></tr></table></figure>

<h3 id="4-2-支持简写"><a href="#4-2-支持简写" class="headerlink" title="4-2 支持简写"></a>4-2 支持简写</h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">background:#336699 url('1.png') no-repeat left top;</span><br></pre></td></tr></table></figure>

<p>使用背景图片的一个常见案例就是很多网站会把很多小图标放在一张图片上，然后根据位置去显示图片。减少频繁的图片请求。</p>
<h3 id="4-3-有趣的例子（图片不动）"><a href="#4-3-有趣的例子（图片不动）" class="headerlink" title="4-3 有趣的例子（图片不动）"></a>4-3 有趣的例子（图片不动）</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">"X-UA-Compatible"</span> <span class="attr">content</span>=<span class="string">"ie=edge"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>滚动背景图示例<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        * &#123;</span><br><span class="line">            margin: 0;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.box</span> &#123;</span></span><br><span class="line">            width: 100%;</span><br><span class="line">            height: 500px;</span><br><span class="line">            background: url("http://gss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=e9952f4a6f09c93d07a706f3aa0dd4ea/4a36acaf2edda3cc5c5bdd6409e93901213f9232.jpg")  center center;</span><br><span class="line">            background-attachment: fixed;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.d1</span> &#123;</span></span><br><span class="line">            height: 500px;</span><br><span class="line">            background-color: tomato;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.d2</span> &#123;</span></span><br><span class="line">            height: 500px;</span><br><span class="line">            background-color: steelblue;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.d3</span> &#123;</span></span><br><span class="line">            height: 500px;</span><br><span class="line">            background-color: mediumorchid;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"d1"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"box"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"d2"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"d3"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="4-4-案例"><a href="#4-4-案例" class="headerlink" title="4-4 案例"></a>4-4 案例</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        div &#123;</span><br><span class="line">            height: 800px;</span><br><span class="line">            width: 800px;</span><br><span class="line"><span class="css">            <span class="comment">/*background-color: red;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*背景图片*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*background-image: url("222.png");  !*默认要全部铺满*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*background-repeat: no-repeat;  !*不铺*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*background-repeat: no-repeat;  !*不铺*!*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*background-repeat:repeat-x;  */</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*background-repeat:repeat-y;  */</span></span></span><br><span class="line">            /*其实浏览器不是一个平面  是一个三维立体结构</span><br><span class="line">            z轴指向用户 越大离用户越近</span><br><span class="line">            */</span><br><span class="line"><span class="css">            <span class="comment">/*background-position:center center;  !*第一个左  第二个上*!*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*如果出现了多个属性名前缀是一样的情况 一般情况下都可以简写 只写前缀*/</span></span></span><br><span class="line"><span class="css">            <span class="selector-tag">background</span>: <span class="selector-tag">red</span> <span class="selector-tag">url</span>("222<span class="selector-class">.png</span>") <span class="selector-tag">no-repeat</span> <span class="selector-tag">center</span> <span class="selector-tag">center</span>;  <span class="comment">/*只需要填上你想要加的参数即可 位置没有关系 参数个数也不做限制 加就显示不加就用默认的设置*/</span></span></span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="5、边框"><a href="#5、边框" class="headerlink" title="5、边框"></a>5、边框</h2><h3 id="5-1-边框属性"><a href="#5-1-边框属性" class="headerlink" title="5-1 边框属性"></a>5-1 边框属性</h3><ul>
<li>border-width</li>
<li>border-style</li>
<li>border-color</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-id">#i1</span> &#123;</span><br><span class="line">  <span class="attribute">border-width</span>: <span class="number">2px</span>;</span><br><span class="line">  <span class="attribute">border-style</span>: solid;</span><br><span class="line">  <span class="attribute">border-color</span>: red;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>通常使用简写方式：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-id">#i1</span> &#123;</span><br><span class="line">  <span class="attribute">border</span>: <span class="number">2px</span> solid red;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="5-2边框样式"><a href="#5-2边框样式" class="headerlink" title="5-2边框样式"></a>5-2边框样式</h3><table>
<thead>
<tr>
<th align="center">值</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">none</td>
<td align="center">无边框。</td>
</tr>
<tr>
<td align="center">dotted</td>
<td align="center">点状虚线边框。</td>
</tr>
<tr>
<td align="center">dashed</td>
<td align="center">矩形虚线边框。</td>
</tr>
<tr>
<td align="center">solid</td>
<td align="center">实线边框。</td>
</tr>
</tbody></table>
<p>除了可以统一设置边框外还可以单独为某一个边框设置样式，如下所示：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-id">#i1</span> &#123;</span><br><span class="line">  <span class="attribute">border-top-style</span>:dotted;</span><br><span class="line">  <span class="attribute">border-top-color</span>: red;</span><br><span class="line">  <span class="attribute">border-right-style</span>:solid;</span><br><span class="line">  <span class="attribute">border-bottom-style</span>:dotted;</span><br><span class="line">  <span class="attribute">border-left-style</span>:none;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="5-3-案例"><a href="#5-3-案例" class="headerlink" title="5-3 案例"></a>5-3 案例</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        p &#123;</span><br><span class="line">            background-color: red;</span><br><span class="line"></span><br><span class="line">            border-width: 5px;</span><br><span class="line">            border-style: solid;</span><br><span class="line">            border-color: green;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">        div &#123;</span><br><span class="line"><span class="css">            <span class="comment">/*border-left-width: 5px;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-left-color: red;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-left-style: dotted;*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*border-right-width: 10px;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-right-color: greenyellow;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-right-style: solid;*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*border-top-width: 15px;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-top-color: deeppink;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-top-style: dashed;*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="css">            <span class="comment">/*border-bottom-width: 10px;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-bottom-color: tomato;*/</span></span></span><br><span class="line"><span class="css">            <span class="comment">/*border-bottom-style: solid;*/</span></span></span><br><span class="line"><span class="css">            <span class="selector-tag">border</span>: 3<span class="selector-tag">px</span> <span class="selector-tag">solid</span> <span class="selector-tag">red</span>;  <span class="comment">/*三者位置可以随意写*/</span></span></span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-id">#d1</span> &#123;</span></span><br><span class="line">            background-color: greenyellow;</span><br><span class="line">            height: 400px;</span><br><span class="line">            width: 400px;</span><br><span class="line"><span class="css">            <span class="selector-tag">border-radius</span>: 50%;  <span class="comment">/*直接写50%即可 长宽一样就是圆 不一样就是椭圆*/</span></span></span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span>穷人  被diss到了  哭泣.png<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>妈拉个巴子,妈拉个巴子,妈拉个巴子,妈拉个巴子<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"d1"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="6、border-radius"><a href="#6、border-radius" class="headerlink" title="6、border-radius"></a>6、border-radius</h2><p>用这个属性能实现圆角边框的效果。</p>
<p>将border-radius设置为长或高的一半即可得到一个圆形。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-id">#di</span>&#123;</span><br><span class="line">  <span class="attribute">border-radius</span>:<span class="number">50%</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h2 id="7、display属性（显示样式）"><a href="#7、display属性（显示样式）" class="headerlink" title="7、display属性（显示样式）"></a>7、display属性（显示样式）</h2><h3 id="7-1-介绍"><a href="#7-1-介绍" class="headerlink" title="7-1 介绍"></a>7-1 介绍</h3><p>用于控制HTML元素的显示效果。</p>
<table>
<thead>
<tr>
<th>值</th>
<th>意义</th>
</tr>
</thead>
<tbody><tr>
<td>display:”none”</td>
<td>HTML文档中元素存在，但是在浏览器中不显示,占用位置也让出。一般用于配合JavaScript代码使用。</td>
</tr>
<tr>
<td>display:”block”</td>
<td>默认占满整个页面宽度，如果设置了指定宽度，则会用margin填充剩下的部分。</td>
</tr>
<tr>
<td>display:”inline”</td>
<td>按行内元素显示，此时再设置元素的width、height、margin-top、margin-bottom和float属性都不会有什么影响。</td>
</tr>
<tr>
<td>display:”inline-block”</td>
<td>使元素同时具有行内元素和块级元素的特点。</td>
</tr>
</tbody></table>
<p><strong>display:”none”与visibility:hidden的区别：</strong></p>
<p>visibility:hidden: 可以隐藏某个元素，但隐藏的元素仍需占用与未隐藏之前一样的空间。也就是说，该元素虽然被隐藏了，但仍然会影响布局。</p>
<p>display:none: 可以隐藏某个元素，且隐藏的元素不会占用任何空间。也就是说，该元素不但被隐藏了，而且该元素原本占用的空间也会从页面布局中消失。</p>
<h3 id="7-2-详细"><a href="#7-2-详细" class="headerlink" title="7-2 详细"></a>7-2 详细</h3><p>HTML5预定义了很多系统标签，大家学习了html标签部分的时候，肯定注意到了，不同的标签在页面中的显示效果是不一样的，比如两个div之间默认会换行显示，而两个span标签却在一行来显示，到底是什么样式控制着标签这种显示效果呢，那就是显示样式display来控制的。</p>
<ul>
<li>display: block;</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">"display: block;"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">span</span> <span class="attr">style</span>=<span class="string">"display: block;"</span>&gt;</span><span class="tag">&lt;/<span class="name">span</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">i</span> <span class="attr">style</span>=<span class="string">"display: block;"</span>&gt;</span><span class="tag">&lt;/<span class="name">i</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">1. 任意标签的display样式值均可以设置为block，那么该标签就会以block方式来显示</span></span><br><span class="line"><span class="comment">2. block方式显示的标签，默认会换行</span></span><br><span class="line"><span class="comment">3. block方式显示的标签，支持所有的css样式</span></span><br><span class="line"><span class="comment">4. block方式显示的标签，可以嵌套所有显示方式的标签</span></span><br><span class="line"><span class="comment">注：标题标签和段落标签虽然也是block显示类标签，但不建议嵌套block显示类标签</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li>display: inline;</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">"display: inline;"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">span</span> <span class="attr">style</span>=<span class="string">"display: inline;"</span>&gt;</span><span class="tag">&lt;/<span class="name">span</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">i</span> <span class="attr">style</span>=<span class="string">"display: inline;"</span>&gt;</span><span class="tag">&lt;/<span class="name">i</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">1. 任意标签的display样式值均可以设置为inline，那么该标签就会以inline方式来显示</span></span><br><span class="line"><span class="comment">2. inline方式显示的标签，默认不会换行</span></span><br><span class="line"><span class="comment">3. inline方式显示的标签，不支持所有css样式(如：不支持手动设置该标签的宽高)</span></span><br><span class="line"><span class="comment">4. inline方式显示的标签，建议只用来嵌套所有inline显示方式的标签</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li>display: inline-block;</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">"display: inline-block;"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">span</span> <span class="attr">style</span>=<span class="string">"display: inline-block;"</span>&gt;</span><span class="tag">&lt;/<span class="name">span</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">i</span> <span class="attr">style</span>=<span class="string">"display: inline-block;"</span>&gt;</span><span class="tag">&lt;/<span class="name">i</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">1. 任意标签的display样式值均可以设置为inline-block，那么该标签就会以inline-block方式来显示</span></span><br><span class="line"><span class="comment">2. inline-block方式显示的标签，具有inline特性，默认不换行</span></span><br><span class="line"><span class="comment">3. inline-block方式显示的标签，也具备block特征，支持所有css样式</span></span><br><span class="line"><span class="comment">4. inline-block方式显示的标签，不建议嵌套任意显示方式的标签</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="7-3-案例"><a href="#7-3-案例" class="headerlink" title="7-3 案例"></a>7-3 案例</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Title<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="css">        <span class="comment">/*#d1 &#123;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    !*display: none;  !*隐藏标签不展示到前端页面并且原来的位置也不再占有了 但是还存在于文档上*!*!*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    display: inline;  !*将标签设置为行内标签的特点*!*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*&#125;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*#d2 &#123;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    display: inline;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*&#125;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*#d1 &#123;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    display: block;  !*将标签设置成块儿级标签的特点*!*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*&#125;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*#d2 &#123;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    display: block;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*&#125;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*#d1 &#123;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    display: inline-block;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*&#125;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*#d2 &#123;*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*    display: inline-block;  !*标签即可以在一行显示又可以设置长宽*!*/</span></span></span><br><span class="line"><span class="css">        <span class="comment">/*&#125;*/</span></span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">"display: none"</span>&gt;</span>div1<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>div2<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">"visibility: hidden"</span>&gt;</span>单纯的隐藏 位置还在<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>div4<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!--&lt;div id="d1" style="height: 100px;width: 100px;background-color: red"&gt;01&lt;/div&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--&lt;div id="d2" style="height: 100px;width: 100px;background-color: greenyellow"&gt;02&lt;/div&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--&lt;span id="d1" style="height: 100px;width: 100px;background-color: red"&gt;span&lt;/span&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--&lt;span id="d2" style="height: 100px;width: 100px;background-color: greenyellow"&gt;span&lt;/span&gt;--&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!--&lt;div id="d1" style="height: 100px;width: 100px;background-color: red"&gt;01&lt;/div&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--&lt;div id="d2" style="height: 100px;width: 100px;background-color: greenyellow"&gt;02&lt;/div&gt;--&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>





</section>
    <!-- Tags START -->
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/python/%E5%89%8D%E7%AB%AF/10-JavaScript%E5%87%BD%E6%95%B0/">
        <span class="nav-arrow">← </span>
        
          python/前端/10-JavaScript函数
        
      </a>
    
    
      <a class="nav-right" href="/python/%E5%89%8D%E7%AB%AF/11-JavaScript%E5%86%85%E7%BD%AE%E6%96%B9%E6%B3%95/">
        
          python/前端/11-JavaScript内置方法
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">点击上方按钮,请我喝杯咖啡！</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Gitment START -->
      <div id="comments"></div>
      <!-- Gitment END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
  <!-- 不蒜子统计 -->
    <strong class="toc-title">目录</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1、宽和高"><span class="toc-nav-text">1、宽和高</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#案例"><span class="toc-nav-text">案例</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#2、字体属性"><span class="toc-nav-text">2、字体属性</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-1-文字字体"><span class="toc-nav-text">2-1 文字字体</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-2-字体大小"><span class="toc-nav-text">2-2 字体大小</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-3-字重（粗细）"><span class="toc-nav-text">2-3 字重（粗细）</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-4-文本颜色"><span class="toc-nav-text">2-4 文本颜色</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-5-总结"><span class="toc-nav-text">2-5 总结</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-6-案例"><span class="toc-nav-text">2-6 案例</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#文字属性"><span class="toc-nav-text">文字属性</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-1-文字对齐"><span class="toc-nav-text">3-1 文字对齐</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-2-文字装饰"><span class="toc-nav-text">3-2 文字装饰</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-3-首行缩进"><span class="toc-nav-text">3-3 首行缩进</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-4-案例"><span class="toc-nav-text">3-4 案例</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4、背景属性"><span class="toc-nav-text">4、背景属性</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-1-基本使用"><span class="toc-nav-text">4-1 基本使用</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-2-支持简写"><span class="toc-nav-text">4-2 支持简写</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-3-有趣的例子（图片不动）"><span class="toc-nav-text">4-3 有趣的例子（图片不动）</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-4-案例"><span class="toc-nav-text">4-4 案例</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#5、边框"><span class="toc-nav-text">5、边框</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#5-1-边框属性"><span class="toc-nav-text">5-1 边框属性</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#5-2边框样式"><span class="toc-nav-text">5-2边框样式</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#5-3-案例"><span class="toc-nav-text">5-3 案例</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#6、border-radius"><span class="toc-nav-text">6、border-radius</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#7、display属性（显示样式）"><span class="toc-nav-text">7、display属性（显示样式）</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#7-1-介绍"><span class="toc-nav-text">7-1 介绍</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#7-2-详细"><span class="toc-nav-text">7-2 详细</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#7-3-案例"><span class="toc-nav-text">7-3 案例</span></a></li></ol></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://www.liuqingzheng.top/python/前端/5-CSS3基础样式/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>



  <script>
    var gitmentConfig = "liuqingzheng";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "python/前端/5-CSS3基础样式",
        owner: "liuqingzheng",
        repo: "FuckBlog",
        oauth: {
          client_id: "32a4076431cf39d0ecea",
          client_secret: "94484bd79b3346a949acb2fda3c8a76ce16990c6"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  </script>




    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
     本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
     本站访客数<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



  <p class="copyright">
    &copy; 2021 | Proudly powered by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank">小猿取经</a>
    <br>
    Theme by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank" rel="noopener">小猿取经</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>





<!-- Baidu Tongji -->

<script>
    var _baId = 'c5fd96eee1193585be191f318c3fa725';
    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>


<script src="/js/script.js"></script>


<script src="/js/search.js"></script>


<script src="/js/load.js"></script>



  <span class="local-search local-search-google local-search-plugin" style="right: 50px;top: 70px;;position:absolute;z-index:2;">
      <input type="search" placeholder="站内搜索" id="local-search-input" class="local-search-input-cls" style="">
      <div id="local-search-result" class="local-search-result-cls"></div>
  </span>


  </body>
</html>